Skip to content

fix(collections): open library-tab collection items without a library scope - #478

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
d3v1l1989:fix/collection-items-unscoped
Oct 10, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
d3v1l1989:fix/collection-items-unscoped

Conversation

@d3v1l1989

@d3v1l1989 d3v1l1989 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A (Apple counterpart: Silo-Server/silo-apple#619)
Validation tasks: none

Opening a collection from a library's Collections tab and selecting an item can show "unavailable" for an item that exists. Both the phone and TV apps open the item with the library the tab belongs to, item detail then reads GET /api/v2/catalog/items/{id}?library_id=N, and the server returns 404 for an item outside that library. User collections often mix libraries, and an admin collection can also be shown in libraries other than its primary one, so any item filed elsewhere fails.

Reproduced against a real server (build-1116) with that request:

  • A 78-item user collection with items in five libraries: 16 items return 404 with library_id set to the library holding most of them, 67 return 404 with another library the collection is shown in, and all 78 return 200 without library_id.
  • A 31-item collection whose items are all in one library: 31/31 return 200 scoped to that library, and 31/31 return 404 scoped to a different one.

Approach

The phone CollectionDetail destination and the TV LibraryCollectionDetail destination now open items without a libraryId. The route's libraryId still loads the collection itself. Personal collections, the web client, and the Apple fix (Silo-Server/silo-apple#619) already open collection items this way.

Main has since added collection shuffle (#476) to the same two destinations, and it started the player with the tab's library too, so a shuffle pick from another library failed with "Watch target not found" (GET /api/v2/watch/{id}?library_id=N returns 404). A follow-up commit on this branch starts collection shuffles without a library on both apps, as Apple does, and removes the phone view model's unused browseLibraryId. The branch is merged with main.

Validation

  • Server behaviour: reproduced with the requests described above.
  • Unit tests: :androidApp:testDebugUnitTest --tests '*CollectionRouteTest*' (6/6, including a new test that finds the scoped call in the old code and passes on the new code) and :androidTvApp:testDebugUnitTest --tests '*TvItemDetailNavigationTest*' (20/20) pass.
  • Build: :androidApp:assembleDebug and :androidTvApp:assembleDebug succeed (JDK 21, Linux container).
  • Not run: the full testDebugUnitTest suite, the lint tasks, and the supply-chain scripts. I have not exercised the change on a device or emulator.

Review follow-up on 6576f924d (merged with main 05b3f916a), against a sandbox built from silo-server main, with a Movies-library collection holding two movies and two series:

  • TV: opening a series from the Movies tab's collection showed "Item not found" on main and opens the series on this branch; playing an episode from there starts.
  • Shuffle, phone and TV: on main the first pick (a series episode) failed with "Watch target not found"; on this branch the series-episode pick plays. Server logs show getWatchState 404 before and 200 after.
  • testDebugUnitTest (all modules), the five lint tasks, and both assembleDebug tasks pass. The supply-chain scripts weren't run locally (the build host has no ruby); CI runs them.
  • Validation tasks: none. No passed validation case covers collections.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-478/

Risks

Items opened from these collection screens no longer send library_id for detail, season, episode, player, or reader reads. That includes items that really are in the tab's library. This matches how items open from Home, Search, Favorites, Watchlist, and personal collections.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated. The human submitter reported the bug and asked for the fix but had not reviewed the diff when this PR was opened.
  • Adversarial review: A separate Claude Code reviewer agent (claude-opus-5-5) traced every consumer of the dropped libraryId (item detail, seasons, episodes, player, audiobook player, book reader, the TV duplicate-entry check) and searched both collection screens for other library-scoped paths. It found none, and confirmed that personal collections behave as before. It flagged that the new test's first version scanned past the collection destination into item detail, which keeps its scope legitimately. That would have made the test fail on any code, so the scan now stops at the detail-screens marker. It also suggested a TV source-scan test and a shared slice helper for the existing test. Neither was added, to keep the change minimal.
  • Review follow-up: the shuffle commit, the merge with main, and the emulator verification were done by Claude Code (claude-opus-5-5) during a maintainer-requested review, with a second opinion from Codex (gpt-6.1-sol).

🤖 Generated with Claude Code

Note

Open library-tab collection items and shuffles without a library scope

Collection items can belong to libraries other than the collection screen's library, so item-detail and shuffle-player navigation no longer forwards that library ID. Applies to both Android (AppNavigation.kt) and TV (TvAppNavigation.kt); TV keeps the existing playback-navigation state argument.

  • Removes the CollectionDetailViewModel accessor that exposed the library ID for shuffled playback
  • Adds a source-based regression test, CollectionRouteTest.collectionItemsAndShufflesOpenWithoutALibraryScope, that fails if item navigation includes a library-scoped argument or shuffle navigation uses the scoped route
  • Behavioral Change: collection item detail and shuffle playback from the collection screen now open unscoped routes instead of library-scoped ones

Macroscope summarized 6576f92.

… scope

Items in a collection opened from a library's Collections tab were read
with that library's id. The server answers 404 for an item scoped to a
library that does not hold it, so any item filed in another library
showed as unavailable. User collections often mix libraries, and admin
collections can be shown in libraries other than their primary one.

Phone and TV now open these items without a library scope, like the
personal Collections screens, the web client, and the Apple clients.
The route's library id still loads the collection itself.
@silo-kody

silo-kody Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7a0f543-007f-4557-97fd-cad5dbbc8fd2

📥 Commits

Reviewing files that changed from the base of the PR and between 421e106 and 6576f92.


📒 Files selected for processing (4)
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/collections/CollectionDetailViewModel.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/CollectionRouteTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da4733a8-5d84-4999-991d-e5da495fb692



📥 Commits

Reviewing files that changed from the base of the PR and between 98b8cea and 421e106.




📒 Files selected for processing (3)
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/CollectionRouteTest.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt



Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Collection-item navigation in the Android and Android TV apps now opens item detail without passing the collection’s library ID. An Android test checks that the collection destination constructs the route without a library ID.

Changes

Collection item navigation

Layer / File(s) Summary
Remove library scope from collection item navigation
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt, androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt, androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/CollectionRouteTest.kt
Android and Android TV collection-item clicks open item detail without passing libraryId. An Android source-inspection test checks that the collection destination does not construct Route.ItemDetail with libraryId.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: rhainland





Merge Risk: ⚪ Minimal · up to 421e1

Both apps now open collection items by content ID without library scope, matching the client’s unscoped request path. No concrete regression is established in the reviewed changes.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 421e1

The navigation fix preserves authentication, but it also introduces another route into shared requests that are not correctly separated across account, server, or profile changes. An overlapping request could deliver previous-session metadata to the replacement session. Existing response checks and scoped storage substantially limit this risk.

Retained concerns

  • Medium · security · inferred: Library-tab collection clicks newly enter an in-flight request path whose production generation key does not track authenticated identity changes. A replacement session can join an old same-content warmup. Although API ownership checks reject changes during the exchange, a transition after that check or during an unguarded cached read can leave previous-session metadata available to the new detail caller. This is an inferred additional path into a pre-existing isolation weakness, not a demonstrated server authorization bypass.
Security review details

Security Blast Radius

  • inferred — The identified isolation risk is bounded to overlapping same-content requests within one running client across identity replacement. The confirmed producer is Android Home warmup; possible exposure is catalog metadata, including returned user-rating data. This does not establish credential leakage, durable cross-owner contamination, or remote service-wide access.

Security Findings and Attack Paths

  • inferred — A replacement profile or account selecting the same content ID can join an earlier process-owned warmup because the repository's production generation does not advance with identity. Exposure requires the earlier result to survive the API guard, followed by an identity change before repository completion, or an overlapping cached read. The new collection path increases reliance on this pre-existing weakness; the scenario has not been reproduced.

Trust Boundaries and Controls

  • observed — Important containment remains: API identity changes return identity_changed; that error and permission/not-found responses do not permit cache fallback. Room reads address server/profile-specific rows, and writes reject stale generation leases. These controls narrow, but do not replace, ownership checks on shared result delivery.

Resilience and Maintainability Implications

  • observed — Warmup producers intentionally survive caller cancellation. Mutex-protected insertion and finally cleanup prevent abandoned in-flight entries after terminal completion, but cleanup does not ensure that callers joining before completion share the same authenticated owner.

Hardening Proposals

  • proposed — Bind CatalogRepository to the shared identity-transition barrier and validate captured ownership after suspending cache operations and before returning or publishing detail data. A production-wiring transition test should cover an old warmup overlapping a replacement identity's collection click, including the post-API and cache-read windows.



Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the primary change: opening collection items without a library scope.
Description check Passed The description directly explains the collection navigation bug, the unscoped navigation approach, affected Android and TV destinations, validation, and behavioral risks.



✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR





  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Quick104 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Silo's pull request guidance changed today (#490). A PR that changes what a user sees now needs before-and-after evidence in its Evidence section, and a PR with no visible change says Evidence: none, no user-visible change. This PR was opened before the rule existed, so it hasn't had a chance to meet it yet.

Missing here: Before-and-after phone and TV screenshots of opening a cross-library item from a library's Collections tab: the unavailable screen before, the detail page after.

The rules are in Show visible changes, and the PR template shows the Evidence section layout. I've converted this PR to draft for now. Mark it ready for review once the Evidence section is filled in.


Generated by Claude Code

@Quick104
Quick104 marked this pull request as draft October 6, 2026 19:25

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 421e106 against current main. The item-click change is correct on its own. Once it merges with main, two things need attention, and one needs a maintainer decision.

1. Collection shuffle still opens with the tab's library (phone and TV). Severity: medium.
Main gained collection shuffle (#476) in the same two destinations this PR changes. On phone, onShuffleStarted calls shufflePlayerRoute(shuffle, libraryId); on TV it calls navigateToTvShufflePlayback(shuffle, libraryId, ...). A collection shuffle draws from the whole collection, but the player sends every pick, later picks included, to GET /api/v2/watch/{id}?library_id=N, and the server returns 404 for an item outside library N.

  • Trigger: a collection in the Movies library that also holds a series. Start Shuffle; any episode it picks fails to play.
  • Evidence: on a sandbox built from silo-server main, GET /api/v2/watch/<episode id> returns 200, and the same request with library_id set to the Movies library returns 404.
  • Repair: start collection shuffles with no library, the same as item clicks. Apple already does this (router.presentShuffle(shuffle)).

I'm fixing this in a commit on this branch, along with the merge from main, so there's no need to change it yourself.

2. The branch conflicts with main.
The conflict is the shuffle callback above, in the phone CollectionDetail destination. I'm resolving it with a merge commit, not a force-push.

3. Needs your call: on main, the phone no longer lists other libraries' items in a library-tab collection.
Since #447, the phone loads a library-tab collection with library_id set (the getLibraryCollectionItems(..., libraryId = libraryId, ...) call in CollectionDetailViewModel), and the server filters the list to that library. TV sends library_id only in a Movies or Series view (libraryId.takeIf { mediaScope != null }). On the sandbox, for a Movies-library collection holding two movies and two series, the request the phone makes returns the two movies, and the request TV makes returns all four.

So on main, the phone's item-click 404 can't be reached any more: those items are hidden instead. The phone half of this PR still keeps phone item clicks consistent with TV, Apple, and the web, and it matters again if the phone list goes back to showing every item. Options:

  • (a) Keep this PR as is and track the phone list separately.
  • (b) Also make the phone list unscoped outside a Movies or Series view in this PR, matching TV.

I'm not changing the list here, since that's #447's behavior and a separate concern.

Review by Claude Code (claude-opus-5-5), with a second opinion from Codex (gpt-6.1-sol).

Quick104 and others added 2 commits October 9, 2026 22:56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cope

A collection shuffle draws from the whole collection, but both apps
started it with the tab's library, so the player asked for each pick
with library_id set and the server returned 404 for any pick filed in
another library. Start collection shuffles unscoped, like item clicks
and the Apple apps, and drop the phone view model's unused
browseLibraryId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment on lines 1181 to 1184
onShuffleStarted = { shuffle ->
navController.navigate(
org.siloserver.silo.android.ui.screens.shuffle.shufflePlayerRoute(
shuffle,
backStackEntry.arguments?.getString("libraryId")?.toIntOrNull(),
),
org.siloserver.silo.android.ui.screens.shuffle.shufflePlayerRoute(shuffle),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

Watch Party solo-playback guard bypass in the collection and series shuffle callbacks starts independent playback without leave confirmation while membership remains active, because PlayerScreen does not leave RoomSession on disposal. Wrap both new onShuffleStarted navigation callbacks in the existing externalSoloGuard.

Prompt for LLM

File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt:

Line 1181 to 1184:

Watch Party solo-playback guard bypass in the collection and series shuffle callbacks starts independent playback without leave confirmation while membership remains active, because PlayerScreen does not leave RoomSession on disposal. Wrap both new onShuffleStarted navigation callbacks in the existing externalSoloGuard.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gap predates this PR, so I'm leaving it out of scope here. The onShuffleStarted callbacks came from main in #476 through the merge; this PR's commit only drops the library argument. On main, none of the three phone shuffle entry points runs the solo guard: the collection and series callbacks in AppNavigation.kt, and the library shuffle in MainScreen.kt (rememberShuffleLauncher { shuffle -> navController.navigate(shufflePlayerRoute(...)) }). externalSoloGuard in AppNavigation.kt covers external routes only. If shuffle should confirm before leaving a Watch Party, all three need the guard at once, and that belongs in its own change against #476's shuffle. I haven't confirmed the leave-on-disposal claim.

Claude Code (claude-opus-5-5)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed—my suggestion incorrectly treated a pre-existing shuffle behavior as a regression introduced by this PR.

Based on the history you’ve described, #478 only removes the library scope from collection navigation and shuffle playback. The callbacks came from #476, and the same guard gap affects all three phone shuffle entry points. Wrapping just the two callbacks I cited would be an incomplete fix, and externalSoloGuard should not be treated as a general shuffle guard without checking its intended use.

I retract this suggestion as a required change for #478. Any Watch Party confirmation change should be reviewed separately across all three entry points.

I also retract the definite claim about PlayerScreen disposal: that behavior has not been verified here and should be traced before asserting that room membership remains active.

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Fit: 9/10 · Readiness: 8/10 — conditional
Reviewed head: 6576f924d (merged with main 05b3f916a). CI is green.

Addressed

  • Collection shuffle kept the tab's library on phone and TV, so a pick from another library failed with "Watch target not found". Fixed in 6576f924d: collection shuffles start without a library, as Apple does. Before and after verified on phone and TV emulators.
  • The branch conflicted with main. Merged in 8d19f241b, keeping main's shuffle callback and this PR's item-click change.
  • The original bug, verified live on TV: opening a series from the Movies tab's collection showed "Item not found" on main, and opens on this branch.

Remaining

  • Needs your call: since fix(mobile): separate movies and series in mixed libraries #447, the phone lists a library-tab collection with library_id, so items from other libraries are hidden rather than failing. TV lists all of them. This PR's phone item-click change keeps phone consistent with TV, Apple, and the web, but on main it no longer fixes a reachable phone 404. Options are in my review above. I recommend (a), merging this as is and tracking the phone list separately.
  • Kody's Watch Party guard note applies to all three phone shuffle entry points on main (from feat(playback): shuffle libraries, series, seasons, and collections on phone and TV #476), not to this change; details in the thread. It's worth its own issue.
  • The PR is still a draft, and the author's "I read and can explain the complete diff" box is unchecked. Both are for the author.

Validated features: no passed validation case covers collections or collection shuffle. Validation tasks: none. The board's per-PR lookup didn't run, so a linked task that hasn't passed yet can't be ruled out.

Checks run: testDebugUnitTest (all modules), the five lint tasks, and both assembleDebug tasks pass locally and in CI. The supply-chain scripts passed in CI only.

Evidence: https://evidence.siloserver.org/r/silo-android/pr-478/

User manual: no change needed. The collections page already says that selecting a title in a collection opens it.

Apple and Android: Apple's counterpart (Silo-Server/silo-apple#619) is merged, and Apple already starts collection shuffles without a library. No further Apple change is needed.

Why these scores: Fit is high because the PR fixes a broken core path (opening and shuffling collection items) at the navigation boundary, and matches how Apple, the web, and personal collections already open items, without adding any setting or API surface. Readiness is held at 8 by the open phone-list decision and the draft status, not by a known defect.

Review by Claude Code (claude-opus-5-5), with a second opinion from Codex (gpt-6.1-sol).

@Quick104
Quick104 marked this pull request as ready for review October 10, 2026 03:36
@Quick104
Quick104 merged commit af99d87 into Silo-Server:main Oct 10, 2026
8 of 9 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T03:40:39.369197Z 6576f92 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants